Skip to content

perf: avoid redundant logger level updates - #356

Open
whoalin1 wants to merge 1 commit into
openfga:mainfrom
whoalin1:devin/1796125003-debug-level-cache
Open

whoalin1 wants to merge 1 commit into
openfga:mainfrom
whoalin1:devin/1796125003-debug-level-cache

Conversation

@whoalin1

@whoalin1 whoalin1 commented Dec 1, 2026

Copy link
Copy Markdown

Summary

Contributes to #337.

Configuration.debug now updates each managed logger only when its level actually changes. This preserves the existing public behavior while avoiding redundant Logger.setLevel() calls when configuration objects are constructed or deep-copied for request models.

This matters because Logger.setLevel() invalidates logging manager caches even when the level is already correct. Request-model construction repeatedly deep-copies the default configuration, so those redundant calls become measurable per-request overhead in applications with many loggers. Regression tests cover both repeated setter calls and deepcopy() configuration creation.

The trust_env overhead described in #337 is not addressed here.

Validation:

  • uv run pytest -q -m 'not integration' --cov-fail-under 60 --cov openfga_sdk test: 647 passed, 12 deselected, 2 subtests passed; coverage 70.77%
  • uv run ruff check .
  • uv run ruff format --check .: 181 files already formatted

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@whoalin1
whoalin1 requested a review from a team as a code owner December 1, 2026 11:37
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 33 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 72d12201-6c22-4650-88a1-6f6ff0d18815
Commits

Reviewing files that changed from the base of the PR and between 60caaa5 and 0e0f8f7.

Files selected for processing: 2

  • openfga_sdk/configuration.py
  • test/configuration_test.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@SoulPancake

Copy link
Copy Markdown
Member

@whoalin1
Thanks, Please sign the EasyCLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants